﻿#region Using statements
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SmartFrequency;
using SmartFrequency.Utils;
#endregion

namespace SmartFrequency.GUI
{
    public partial class RecordSettings : Form
    {
        #region Private variables
        private Language FromLanguage;
        private Settings PSettings;
        private Utilities PUtils = new Utilities();
        int buffer;
        #endregion

        #region public functions
        public RecordSettings()
        {
            InitializeComponent();

            this.Text = PUtils.Version;
            PSettings = new Settings("settings.txt");
            PSettings.Load();

            switch (PSettings.GetMember("language"))
            {
                default:
                case "tr":
                    FromLanguage = new Language(Language.Language_e.TR);
                    label1.Left += 20;
                    break;
                case "eng":
                    FromLanguage = new Language(Language.Language_e.ENG);
                    break;
            }

            label1.Text = FromLanguage.FrmMsgToString(Language.FormMsg_e.FORM2_HEAD);
            label2.Text = FromLanguage.FrmMsgToString(Language.FormMsg_e.FORM2_LABEL1);
            label3.Text = FromLanguage.FrmMsgToString(Language.FormMsg_e.FORM2_LABEL2);
            label4.Text = FromLanguage.FrmMsgToString(Language.FormMsg_e.FORM2_LABEL3);
            label5.Text = FromLanguage.FrmMsgToString(Language.FormMsg_e.FORM2_LABEL4);
            label6.Text = FromLanguage.FrmMsgToString(Language.FormMsg_e.FORM2_LABEL5);
            label7.Text = FromLanguage.FrmMsgToString(Language.FormMsg_e.FORM2_LABEL6);

            menuItem2.Text = FromLanguage.FrmMsgToString(Language.FormMsg_e.MENU1_TEXT);

            comboBox1.Text = PSettings.GetMember("samplingrate");
            comboBox2.Text = PSettings.GetMember("bitspersample");
            comboBox3.Text = PSettings.GetMember("channelno");
            textBox1.Text = PSettings.GetMember("duration");
            textBox2.Text = PSettings.GetMember("recordbuffer");
        }

        private void menuItem2_Click(object sender, EventArgs e)
        {
            PSettings.SetMember("samplingrate", comboBox1.Text);
            PSettings.SetMember("bitspersample", comboBox2.Text);
            PSettings.SetMember("channelno", comboBox3.Text);
            PSettings.SetMember("duration", textBox1.Text);
            PSettings.SetMember("recordbuffer", textBox2.Text);
            PSettings.SetMember("playbuffer", textBox2.Text);
            PSettings.Store();
            Dispose();
        }
        #endregion

        private void SettingsTextChanged(object sender, EventArgs e)
        {
            if ((comboBox1.Text != "") && (comboBox2.Text != ""))
            {
                buffer = (Convert.ToInt32(comboBox1.Text) * Convert.ToInt32(comboBox2.Text) * 2) / 8;
                textBox2.Text = Convert.ToString(buffer);
            }
        }

        private void RecordSettings_Paint(object sender, PaintEventArgs e)
        {

        }
    }
}